<?php
Zend_Session::start();
// Khai báo đối tương Zend_Acl
$acl = new My_Acl();
// Khai báo Aclplugin cho front Controller biết
$frontController = Zend_Controller_Front::getInstance();
$frontController->registerPlugin(new My_Aclplugin($acl));

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
    protected function _initNamespaces()
    {
        Zend_Loader_Autoloader::getInstance()->registerNamespace('My_');
        Zend_Loader_Autoloader::getInstance()->registerNamespace('NVL_');
    }
    protected function _initAutoload() {
    
    	$autoloader = new Zend_Application_Module_Autoloader(array(
    			'namespace' => 'Application',
    			'basePath' => dirname(__FILE__),
    	));
    	//var_dump($autoloader);
    	$front = Zend_Controller_Front::getInstance();
    	$front->registerPlugin(new Zend_Controller_Plugin_ErrorHandler(array(
    			'module'     => 'error',
    			'controller' => 'error',
    			'action'     => 'error'
    	)));
    	return $autoloader;
    	
    }
    protected function _initDb()
    {
    
    	$dbOption = $this->getOption('resources');
    	$dbOption = $dbOption['db'];
    
    	// Setup database
    	$db = Zend_Db::factory($dbOption['adapter'], $dbOption['params']);
    
    	$db->setFetchMode(Zend_Db::FETCH_ASSOC);
    	$db->query("SET NAMES 'utf8'");
    	$db->query("SET CHARACTER SET 'utf8'");
    
    	Zend_Registry::set('connectDB', $db);
    
    	//Khi thiet lap che do nay model moi co the su dung duoc
    	Zend_Db_Table::setDefaultAdapter($db);
    
    	// Return it, so that it can be stored by the bootstrap
    	return $db;
    }
    protected function _initDatabase(){
    	$db = $this->getPluginResource('db')->getDbAdapter();
    	Zend_Registry::set('db', $db);
    }
    

}

